﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AMOOF {
    public partial class FormMain : Form {
        public FormMain() {
            InitializeComponent();
        }


        private string[] pdfs = {
                                "TransformedBeta",
                                "GeneralizedPareto",
                                "Burr",
                                "InverseBurr",
                                "Pareto",
                                "InverseParalogistic",
                                "TransformedGamma",
                                "InverseTransformedGamma",
                                "Gamma",
                                "InversePareto",
                                "Loglogistic",
                                "Paralogistic",
                                "InverseGamma",
                                "Weibull",
                                "InverseWeibull",
                                "Exponential",
                                "InverseExponential",
                                "Lognormal",
                                "InverseGaussian",
                                "SingleParameterPareto",
                                "GeneralizedBeta",
                                "Beta"
                            };

        private Report[] reports;

        private Solver solver = new Solver();


        private void btnBuildExcelFile_Click(object sender, EventArgs e) {
            DataImport dataImport = new DataImport();

            var dataMoments = new Dictionary<int, double>();
            dataMoments.Add(1, 7705.140111380320000);
            dataMoments.Add(2, 60518786.77488230000);
            dataMoments.Add(3, 482495163377.5470000);
            dataMoments.Add(4, 3894146431851140.000);
            dataMoments.Add(-1, 0.000233161642895359);
            dataMoments.Add(-2, 0.000100018423443343);
            dataMoments.Add(-3, 0.000100000002710720);
            dataMoments.Add(-4, 0.000100000000000449);


            if (reports == null) {
                reports = new Report[pdfs.Length];
            }
            
            for (int i = 0; i < pdfs.Length; i++) {
                reports[i] = new Report();
                reports[i].PDF = Reflector.GetClass<PDF>("AMOOF." + pdfs[i]);
            }
            //((RPDFStatistics)r).PDF = Reflector.GetClass<PDF>("AMOOF.R22." + name);

            
            solver.LoadData(dataImport.importData(dataImport.openFile(), 0));
            solver.LoadDataMoments(dataMoments);
            foreach (Report r in reports) {
                solver.BuildReport(r);
            }
            //while (!solver.SafelyRemove()) ;
        }

        private void btnRunSolver_Click(object sender, EventArgs e) {

            foreach (Report r in reports) {
                solver.RunSolver(r);
            }



           //while (!solver.SafelyRemove()) ;
        }
    }
}
